<?php
/* @var $this NewsController */
/* @var $model News */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'news-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	//'enableAjaxValidation'=>false,
    'enableClientValidation'=>true,
    'clientOptions'=>array(
            'validateOnSubmit'=>true,
    ),
)); ?>

	<p class="note">带 <span class="required">*</span> 的项目必填.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'news_type'); ?>
		<?php //echo $form->textField($model,'news_type'); ?>
		<?php echo $form->dropDownList($model,'news_type',NewsType::model()->getListArray()); ?>
		<?php echo $form->error($model,'news_type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'news_title'); ?>
		<?php echo $form->textField($model,'news_title',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'news_title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'news_content'); ?>
		<?php //echo $form->textArea($model,'news_content',array('rows'=>6, 'cols'=>50)); ?>
		<?php $this->widget('ext.KEditor.KEditor',array(  
    	            'model'=>$model,  //传入form model  
    	            'name'=>'news_content', //设置name  
    	            'properties'=>array(  
    	                //设置接收文件上传的action  
    	                'uploadJson'=>'index.php?r=admin/news/upload',  
    	                //设置浏览服务器文件的action，这两个就是上面配置在/admin/default的  
    	                'fileManagerJson'=>'index.php?r=admin/news/manageJson',  
    	                                'items'=>array('source', '|', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',  
    			                        'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',  
    			                        'insertunorderedlist', '|',  'image', 'insertfile', 'link','unlink'),    
    	                'newlineTag'=>'br',  
    	                'allowFileManager'=>true,  
    	                //传值前加js:来标记这些是js代码  
    	                'afterCreate'=>"js:function() {  
    	                        K('#ChapterForm_all_len').val(this.count());  
    	                        K('#ChapterForm_word_len').val(this.count('text'));  
    	                    }",  
    	                'afterChange'=>"js:function() {  
    	                        K('#ChapterForm_all_len').val(this.count());  
    	                        K('#ChapterForm_word_len').val(this.count('text'));  
    	                    }",  
    	            ),   
    	            'textareaOptions'=>array(  
    	                'style'=>'width:500px;height:200px;',  
    	            )  
    	        )); ?>  
		<?php echo $form->error($model,'news_content'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'news_add_time'); ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker',array(  
		                'model'=>$model,
                        'attribute' => 'news_add_time',  
		                //'name'=> 'news_add_time',
                        'language' => 'zh_cn',
		                'value' => $model->news_add_time,
                        'options' => array(  
                             'showAnim' => 'fold',
                             'dateFormat' => 'yy-mm-dd',  
                        ),  
                         'htmlOptions'=>array(
                             'style'=>'height:20px;',
                             'value' => date('Y-m-d',$model->news_add_time==0 ? time(): intval($model->news_add_time)),

                      ), 
             ));  
        ?>
		<?php echo $form->error($model,'news_add_time'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->